package com.tourismhengyang.impl;

import java.io.IOException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.tourismhengyang.beans.TrainTicket;
import com.tourismhengyang.biz.ITrainTicketBiz;
import com.tourismhengyang.dao.DBAccess;

public class TrainTicketBizImpl implements ITrainTicketBiz {
	private DBAccess db = new DBAccess();
	
	@Override
	public List<TrainTicket> getTrainTickets(TrainTicket tt) {
		SqlSession session = null;
		List<TrainTicket> result = null;
		try {
			session = db.getSqlSession();
			ITrainTicketBiz trainTicketBiz = session.getMapper(ITrainTicketBiz.class);
			result = trainTicketBiz.getTrainTickets(tt);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

	@Override
	public TrainTicket getOneTicket(TrainTicket tt) {
		SqlSession session = null;
		TrainTicket result = null;
		try {
			session = db.getSqlSession();
			ITrainTicketBiz trainTicketBiz = session.getMapper(ITrainTicketBiz.class);
			result = trainTicketBiz.getOneTicket(tt);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}
}
